<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String willName1 = (new SimpleDateFormat("yyyyMMddHHmmss")
			.format(new Date()) + "_" + new Random().nextInt(1000));
	String willName2 = (new SimpleDateFormat("yyyyMMddHHmmss")
			.format(new Date()) + "_" + new Random().nextInt(1000));
%>
<html>
<head>
<title>新增窗口</title>
<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/ajaxupload.js"></script>
</head>
<body>
<body onunload="refresh()">
	<div
		style="margin-right: 60px; margin-top: 6px; text-align: right; font-weight: bold;">
		<input type="button" value="  保存  " onclick="save()">
	</div>
	<hr />
	<div style="margin-left: 10px;">
		<div>
			username：<input type="text" id="username" style="height: 20px;" />
			file：<input type="file" name="myFile" id="myFile" 
				width="300px;" style=""/><br /> <br />
		</div>
	</div>

	<script type="text/javascript">
	function save(){
		$.post(url,
	           data,
	           function(data, textStatus){
			  		if(data.flag){
			  			alert("成功!" );
			  		}
			   },"json");
			   
	}
	$(function(){
		new AjaxUpload('#myFile', {
			action: '<%=path%>/uploadFileByStruts2.action?filena=<%=willName1%>',
			name: 'myFile',
			autoSubmit:true,
			onComplete : function(file, extension){
				if(extension == ""){
					alert("上传成功！" + file);
				}else{
					alert("上传失败！" + file + extension);
				}
			}	
		});
	});
</script>
</body>
</html>
